#ifndef __HOLDER_H__
#define __HOLDER_H__

#include <vector>
#include <map>
#include <string>
#include "transaction.h"
#include "price_quantity.h"

namespace stock_trade{
class Holder{
public:
    Holder(){isComplete = false;}
    void DecideNumDynamic(Transaction& transaction);

    bool process(Transaction& transaction);
    bool Buy(Transaction& transaction);
    bool Sell(Transaction& transaction);

    bool processFix(Transaction& transaction);
    bool BuyFix(Transaction& transaction);
    bool SellFix(Transaction& transaction);

    float GetCurrentPrice(Stock stock, Date date, Time time);
    float GetCurrentValue(Date date, Time time);
    void PrintFailedLog() const;
    void Clean();

    float cash;
    float validCash;
    std::map<std::string, std::vector<Transaction> > stockHolder;
    std::vector<Transaction> log;
    std::vector<Transaction> failedLog;
    bool isComplete;
    static int holderDay;
    static float fee;
    static int minUnit;
private:
    bool buy(Transaction& transaction);
    bool sell(Transaction& transaction);
    int realBuy(const Transaction& transaction);
    int realSell(const Transaction& transaction);
};
}
#endif
